package com.wyp168.jse;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @ClassName ParallelStreamDemo001
 * @Description TODO
 * @Author wyp168
 * @Date 2022/7/11 14:08
 */
public class ParallelStreamDemo001 {

    public static void main(String[] args) {

        List integers = new ArrayList<>();
        for (int i = 0; i < 200005; i++) {
            integers.add(i);
        }

        List strings = new CopyOnWriteArrayList();

        long start = System.currentTimeMillis();
        integers.parallelStream().forEach(i -> {
//            System.out.println(Thread.currentThread().getName() + "----->" + i);
            strings.add(i.toString());
        });
        long end = System.currentTimeMillis();

        System.out.println("共耗时 " + (end-start) + " ms");

//        System.out.println(strings);

    }
}
